package com.ruoyi.web.controller.ufox;


import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ufox.domain.BisDeviceDataDay;
import com.ruoyi.ufox.domain.BisDeviceDataMonth;
import com.ruoyi.ufox.service.IBisDeviceDataMonthService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.List;

/**
 * 数据月统计Controller
 * 
 * @author ufoxs
 * @date 2022-08-22
 */
@RestController
@RequestMapping("/bussiness/monthdata")
public class BisDeviceDataMonthController extends BaseController
{
    @Autowired
    private IBisDeviceDataMonthService bisDeviceDataMonthService;

    /**
     * 查询数据月统计列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:monthdata:list')")
    @GetMapping("/list")
    public TableDataInfo list(BisDeviceDataMonth bisDeviceDataMonth)
    {
        startPage();
        List<BisDeviceDataMonth> list = bisDeviceDataMonthService.selectBisDeviceDataMonthList(bisDeviceDataMonth);
        return getDataTable(list);
    }

    /**
     * 导出数据月统计列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:monthdata:export')")
    @Log(title = "数据月统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BisDeviceDataMonth bisDeviceDataMonth)
    {
        List<BisDeviceDataMonth> list = bisDeviceDataMonthService.selectBisDeviceDataMonthList(bisDeviceDataMonth);
        ExcelUtil<BisDeviceDataMonth> util = new ExcelUtil<BisDeviceDataMonth>(BisDeviceDataMonth.class);
        util.exportExcel(response, list, "数据月统计数据");
    }

    /**
     * 获取数据月统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:monthdata:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(bisDeviceDataMonthService.selectBisDeviceDataMonthByRecordId(recordId));
    }

    /**
     * 新增数据月统计
     */
    @PreAuthorize("@ss.hasPermi('bussiness:monthdata:add')")
    @Log(title = "数据月统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BisDeviceDataMonth bisDeviceDataMonth)
    {
        return toAjax(bisDeviceDataMonthService.insertBisDeviceDataMonth(bisDeviceDataMonth));
    }

    /**
     * 修改数据月统计
     */
    @PreAuthorize("@ss.hasPermi('bussiness:monthdata:edit')")
    @Log(title = "数据月统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BisDeviceDataMonth bisDeviceDataMonth)
    {
        return toAjax(bisDeviceDataMonthService.updateBisDeviceDataMonth(bisDeviceDataMonth));
    }

    /**
     * 删除数据月统计
     */
    @PreAuthorize("@ss.hasPermi('bussiness:monthdata:remove')")
    @Log(title = "数据月统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(bisDeviceDataMonthService.deleteBisDeviceDataMonthByRecordIds(recordIds));
    }
    @GetMapping("/ss")
    public AjaxResult getTimg(String deviceCode,String yearMonth) {
        List<BisDeviceDataMonth> list=bisDeviceDataMonthService.getTimg(deviceCode, yearMonth);

        return new AjaxResult(200,"",list);
    }

}
